package com.github.datalineage;

import com.github.datalineage.data.Node;
import com.github.datalineage.data.Relation;
import com.github.datalineage.data.Tuple;
import com.github.datalineage.graphdb.Neo4jAdapter;

import java.util.List;

public class TestNeo4j {
    public static void searchLink() {
        Node node1=new Node();
        node1.setType("Org");
        node1.setCode("czyqk");
        node1.setName("川中油气矿");
        Neo4jAdapter neo4jAdapter=new Neo4jAdapter();
        neo4jAdapter.open("bolt://36.134.87.10:18289", "neo4j", "password");
        List<Tuple> results=neo4jAdapter.searchLink(node1.getType(), null, node1.getCode());
        neo4jAdapter.close();
        System.out.println(results);
    }

    public static void searchEffect() {
        Node node1=new Node();
        node1.setType("Org");
        node1.setCode("czyqk");
        node1.setName("川中油气矿");
        Neo4jAdapter neo4jAdapter=new Neo4jAdapter();
        neo4jAdapter.open("bolt://36.134.87.10:18289", "neo4j", "password");
        List<Node> results=neo4jAdapter.searchEffect(node1.getType(), node1.getCode());
        neo4jAdapter.close();
        System.out.println(results);
    }

    public static void createLink() {
        Node node1=new Node();
//        node1.setType("Org");
//        node1.setCode("gsmyt");
//        node1.setName("公山庙油田");
//        node1.setType("Org");
//        node1.setCode("qlqt");
//        node1.setName("秋林油田");
        node1.setType("Org");
        node1.setCode("plzqt");
        node1.setName("蓬莱镇气田");
        Node node2=new Node();
        node2.setType("Org");
        node2.setCode("czyqk");
        node2.setName("川中油气矿");
        Relation relation=new Relation();
        relation.setCode("PARENT");
        relation.setName("属于");
        Neo4jAdapter neo4jAdapter=new Neo4jAdapter();
        neo4jAdapter.open("bolt://36.134.87.10:18289", "neo4j", "password");
        neo4jAdapter.creatLink(node1, node2, relation);
        neo4jAdapter.close();
    }

    public static void main(String[] args) throws Exception {
        searchEffect();
        //createLink();
    }
}
